/*!\ file Battleship.cpp
 * \ author CT Ortman / Matthew Richard
 * \ Latest Update: 4/15/13
 * \ brief This is the file for running a basic instance of battleship.
 */

#include <iostream>
using namespace std;
#include "Battleship.h"


int main()
{
  bool player1 = true; // Value to pass to an instance of a game to identify whether the owner of that instance is Player 1 or not
  Battleship p1(player1); // Instance of the game for Player 1
  Battleship p2(!player1); // Instance of the game for Player 2
  p1.getPlacement(p2.giveBoard());  // Exchanging the initial placements of both
  p2.getPlacement(p1.giveBoard());  // players so their boards will match
  while(!(p1.winCondition()||p2.winCondition())) // Game continues until one players wins
  {
    p2.updateBoard(p1.takeTurn());  // Player 1 takes his turn, which returns the new board so that player 2's game instance can update the changes
    if(!p1.winCondition())  // Only continue if p1 didn't win from his last move
    {
      p1.updateBoard(p2.takeTurn()); // Player 2 takes his turn, and returns the new board so player 1's game instance can update it's board
    }
  }
  
  // Depending on who wins, output the result
  if(p1.winCondition())
    cout << "Player 1 wins!";
  else
    cout << "Player 2 wins!";
  return 0;
}
